/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.user.controller;

import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.user.service.UserApiConfigService;
import com.pig4cloud.pigx.user.vo.UserApiConfigDetailVO;
import com.pig4cloud.pigx.user.vo.UserApiConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * api配置表
 *
 * @since 2022-10-31 15:36:10
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/userapiconfig")
@Api(value = "userapiconfig", tags = "api配置表管理")
public class UserApiConfigController {

	private final UserApiConfigService userApiConfigService;

	/**
	 * 查询详情
	 *
	 * @return {@link R< UserApiConfigVO>}
	 * @since 2022/10/31 19:45
	 */
	@ApiOperation(value = "查询详情", notes = "查询详情")
	@GetMapping
	// @PreAuthorize("@pms.hasPermission('user_api_config_view')")
	public R<UserApiConfigDetailVO> detail() {
		UserApiConfigDetailVO vo = userApiConfigService.detail();
		return R.ok(vo);
	}

	/**
	 * 修改
	 *
	 * @return {@link R< UserApiConfigVO>}
	 * @since 2022/10/31 19:45
	 */
	@ApiOperation(value = "查询详情", notes = "查询详情")
	@PutMapping
	// @PreAuthorize("@pms.hasPermission('user_api_config_edit')")
	public R<UserApiConfigVO> update(@Validated @RequestBody UserApiConfigVO param) {
		userApiConfigService.update(param);
		return R.ok();
	}
}
